package com.warm.controller;

import com.warm.service.SecKillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by liangchuang on 2018/10/5.
 * Description:
 */
@RestController
@RequestMapping("/kill")
@Slf4j
public class SeckillController {
    @Autowired
    private SecKillService secKillService;

    /**
     * @Description: 查询秒杀活动特价商品的信息
     * @param productId :
     * @return : java.lang.String
     * @Date: 2018/10/5
     */
    @GetMapping("/query/{productId}")
    public String query(@PathVariable String productId)throws Exception{
        return secKillService.querySecKillProductInfo(productId);
    }

    @GetMapping("/order/{productId}")
    public String skill(@PathVariable String productId)throws Exception{
        log.info("@skill request, productId:" + productId);
        secKillService.orderProductMockDiffUser(productId);
        return secKillService.querySecKillProductInfo(productId);
    }
}
